<?php
// Validate date in following format "2012-11-19"
function validateDate($date) {
	$dateComponents = explode("-", $date);	
	if (count($dateComponents) == 3) {
		return checkdate($dateComponents[1],$dateComponents[1],$dateComponents[0]);
	} 
	return false;
}
// validates time in the following format "16:55:49"
function validateTime($time) {
	$dateComponents = explode(":", $time);
	if (count($dateComponents) == 3) {
		return ($dateComponents[0] >= 0 && $dateComponents[0] <= 23 && $dateComponents[1] >=0 && $dateComponents[1] <=  59 && $dateComponents[2] >= 0 && $dateComponents[2] <= 59);
	}
	return false;
}

// Validate date time in following format "Y-m-d H:M:S"
function validateDateTime($date) {
	$dateComponents = explode(" ", $date);
	if (count($dateComponents) == 2) 
		return (validateDate($dateComponents[0]) && validateTime($dateComponents[1]));
	return false;
}
?>